<template>
    <div class="sidebar-item"
         :class="{active:current === item.path}"
         @click="handleClick">
        <span></span>
        <span class="title">{{item.title}}</span>
    </div>
</template>

<script>
export default {
    name: "sidebarItem",
    props: {
        item: {
            type: Object
        },
        current: {
            type: String,
            default: '/demo'
        }
    },
    data () {
        return {
            msg: ""
        };
    },
    computed: {},
    methods: {
        handleClick () {
            let current = this.$router.history.current.path;
            if (current !== this.item.path) {
                this.$router.push({
                    path: `${this.item.path}`
                });
            }

            this.$emit("change", this.item);
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.sidebar-item {
    box-sizing: border-box;
    padding-left: 40px;
    width: 100%;
    height: 55px;
    line-height: 55px;
    font-size: 19px;
    cursor: pointer;

    &:hover {
        background: rgb(68, 89, 117);
    }
}
.active {
    background: #d03a56;
    &:hover {
        background: #d03a56;
    }
}
</style>
